package com.zeta.api.client.system;

import com.zeta.api.model.UserInfoDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * 系统服务-用户 Feign接口降级处理
 *
 * @author gcc
 */
@Slf4j
@Component
public class IUserApiFallbackFactory implements FallbackFactory<IUserApi> {

    @Override
    public IUserApi create(Throwable cause) {
        log.error("系统服务-用户 feign接口调用失败: {}", cause.getMessage());

        return new IUserApi() {
            @Override
            public UserInfoDTO getUserInfoById(Long id) {
                return null;
            }

            /**
             * 批量获取用户基础信息
             *
             * @param ids 用户id列表
             * @return List<UserInfoDTO>
             */
            @Override
            public List<UserInfoDTO> getUserInfoByIds(List<Long> ids) {
                return Collections.emptyList();
            }
        };
    }
}
